Add Grad-CAM interpretability method#887
Open
JunboShen wants to merge 1 commit intosunlabuiuc:masterfrom
Open
Conversation
jhnwu3
reviewed
Mar 13, 2026
Collaborator
jhnwu3
left a comment
There was a problem hiding this comment.
WIll take a deeper look later.
But, @JunboShen if you're not already in the discord, would love to have you join the interpretability team.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributor: Junbo Shen
Contribution Type: Interpretability method, tests, example
Description
Add
GradCAMtopyhealth.interpret.methodsfor CNN-based medicalimage classification.
Main behavior:
target_layeras either annn.Moduleor a dotted path such asmodel.layer4.1.conv2{input_key: cam}with shape[B, H, W]class_indexis not providedlogitwhen available and falls back toy_probotherwiseAnd add:
Files added/changed
pyhealth/interpret/methods/gradcam.pytests/core/test_gradcam.pyexamples/cxr/gradcam_cxr_tutorial.pydocs/api/interpret.rstdocs/api/interpret/pyhealth.interpret.methods.gradcam.rstdocs/tutorials.rstTesting
Validated locally with:
The Grad-CAM implementation was also checked against the original
jacobgil/pytorch-grad-camimplementation by comparing the output.